package view;

import mock.MockGameState;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created with IntelliJ IDEA.
 * User: Student
 * Date: 29/11/12
 * Time: 16:25
 * To change this template use File | Settings | File Templates.
 */
public class ActionPanel extends JPanel implements ActionListener {
    public ActionPanel() {
        setBorder(BorderFactory.createTitledBorder("Action"));
        setLayout(new FlowLayout());
        JButton rollButton = new JButton("Roll");
        add(rollButton);
        rollButton.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        GamePanel instance = GamePanel.getInstance();
        MockGameState mockGameState = MockGameState.getInstance();
        mockGameState.roll();
        if (instance != null)
            instance.update(mockGameState);
    }
}
